Return to Video

https:/.../xml_css_entities.mp4

  • 0:53 - 0:59
    Okay. I'm back, and the first part
    of this lecture is gonna cover entities.
  • 0:59 - 1:04
    And then I'll break again, and cover
    the CSS piece in a separate recording.
  • 1:08 - 1:10
    There's really two different
    types of entities.
  • 1:10 - 1:14
    One of them you can use, general
    entities, to lure data into XML documents,
  • 1:14 - 1:20
    and then you can use parameter
    entity references, um...
  • 1:20 - 1:23
    to make data become part of the DTD.
  • 1:23 - 1:25
    For example, for general entity,
  • 1:25 - 1:28
    you would use them for common
    strings of text that we'd like to
  • 1:28 - 1:31
    define in a single place,
    and use it multiple times.
  • 1:31 - 1:35
    Some of those might be,
    for example, a company name.
  • 1:35 - 1:38
    If you were to use the same
    document to generate, say,
  • 1:38 - 1:40
    a report for different companies,
  • 1:40 - 1:44
    instead of trying to go in and edit
    the company name for each company
  • 1:44 - 1:47
    that you generate the report from,
    if you use a general entity,
  • 1:47 - 1:52
    you could define it in one place, and
    then publish the report for one company,
  • 1:52 - 1:57
    and then go change the variable,
    that text from one place
  • 1:57 - 2:00
    and print the report for
    the second company.
  • 2:00 - 2:05
    So it lets you kind of, almost like a
    variable, or in something like Frame,
  • 2:05 - 2:09
    or even Word has something like this.
  • 2:09 - 2:11
    So, you can use string substitutions.
  • 2:14 - 2:19
    Another example might be, say that
    you're developing some documentation
  • 2:19 - 2:24
    for a software project, and the name of
    the software might change if you,
  • 2:24 - 2:29
    a lot of times, the names of things when
    you're working on software projects,
  • 2:29 - 2:31
    they are not always stable.
  • 2:31 - 2:36
    And you know that the product name might
    change, or a menu item might change.
  • 2:36 - 2:42
    Instead of typing that menu item all
    over the place, you could make an entity,
  • 2:42 - 2:46
    insert that entity in your documents,
    and then if they do change the name,
  • 2:46 - 2:49
    you only have to change it
    in the one place,
  • 2:49 - 2:52
    instead of all over all the different files.
  • 2:55 - 3:02
    The example uses of a parameter
    entity would be, sometimes you have,
  • 3:02 - 3:06
    once you start building out all the DTDs
    that you would need for a doc set,
  • 3:06 - 3:10
    there might be some information
    that's used in multiple DTDs;
  • 3:10 - 3:17
    for example, addresses. You might
    have addresses in several different
  • 3:17 - 3:24
    deliverables, or documents. And instead
    of defining those elements for address
  • 3:24 - 3:29
    repeatedly in all of these different
    DTDs, you could define those,
  • 3:29 - 3:31
    the elements that make up
    an address, in one DTD,
  • 3:31 - 3:36
    and then make pointers to all those
    other DTDs to that one location.
  • 3:36 - 3:38
    And it helps you single-source,
  • 3:38 - 3:41
    and not have to keep redefining
    the will all the time,
  • 3:41 - 3:44
    or keep redefining the same
    sort of structure all the time.
  • 3:45 - 3:46
    So, we'll go through that.
  • 3:46 - 3:51
    It's a little fuzzy right now, I'm sure,
    from just a description.
  • 3:51 - 3:57
    But it's just ways to either re-use text
    in an XML file, or to re-use the structure
  • 3:57 - 4:02
    that you defined in one DTD
    in another DTD, instead of redefining it.
  • 4:03 - 4:07
    Walking through this example with, like,
    the contact element that we've seen
  • 4:07 - 4:09
    in other lectures.
  • 4:13 - 4:16
    So here's an example of a general entity.
  • 4:16 - 4:20
    And you'll notice that
    it's defined in your DTD.
  • 4:22 - 4:26
    And it has almost the same structure
    as Element; it's a little bit different,
  • 4:26 - 4:30
    in that, instead of Element, it says Entity.
  • 4:30 - 4:33
    And then it has the name of the entity,
  • 4:33 - 4:36
    and then what you want
    the substitution to be.
  • 4:36 - 4:42
    So for example, we're, in this example,
    creating an entity called Company.
  • 4:42 - 4:45
    And in your XML file, you want
    wherever you put the entity,
  • 4:45 - 4:48
    you want it to say "XYZ Software."
  • 4:51 - 4:53
    So how does this work in your XML instant?
  • 4:53 - 4:57
    If you remember back when
    we talked about apostrophes,
  • 4:57 - 5:01
    and those special characters
    that you can't type,
  • 5:01 - 5:05
    and you have to use those special
    symbols for them, the ampersand,
  • 5:05 - 5:07
    the less-than, the greater than.
  • 5:08 - 5:09
    Those symbols?
  • 5:09 - 5:11
    It has the same structure.
  • 5:12 - 5:16
    If you remember back to the ampersand,
    when you want to insert an ampersand
  • 5:16 - 5:21
    into your document, you had to do
    the ampersand, AMP, semi-colon?
  • 5:21 - 5:27
    It's the same thing for if you define
    your own entity reference.
  • 5:27 - 5:34
    So for example, how we defined it here
    is ampersand, company. Semi-colon.
  • 5:39 - 5:41
    Sorry; I have to put the cursor here.
  • 5:42 - 5:43
    So it's there.
  • 5:43 - 5:45
    Ampersand company, semi-colon.
  • 5:46 - 5:50
    And here's another use of it. And you
    can use it as many times as you want
  • 5:50 - 5:54
    in your file, and if you have multiple
    files used in the same DTD,
  • 5:54 - 6:00
    you just use the ampersand-company-
    semi-colon wherever you want,
  • 6:00 - 6:06
    as many times as you need to, and every
    time that this document is transformed,
  • 6:06 - 6:11
    it will turn that ampersand-company-
    semi-colon into "XYZ Software."
  • 6:12 - 6:16
    So for example, this is what
    the output looks like now.
  • 6:16 - 6:20
    Where you saw the company,
    ampersand company,
  • 6:20 - 6:22
    it's now saying XYZ Software.
  • 6:22 - 6:27
    XYZ Software. Let's go back and look
    at previous page a moment again.
  • 6:28 - 6:34
    This is the customer list for &Company;
    organization company.
  • 6:35 - 6:42
    And that's been transformed into
    XYZ Software, XYZ Software.
  • 6:45 - 6:48
    Now, if you wanted to
    go back into DTD now,
  • 6:48 - 6:54
    and change that entity reference
    to say ABC Software,
  • 6:54 - 6:57
    then the value would also
    change after you output it,
  • 6:57 - 7:00
    without you touching your XML instance.
  • 7:00 - 7:04
    XML instance still says
    &Company;.
  • 7:04 - 7:08
    All you do is you change it in the
    DTD, you re-run the transformation,
  • 7:08 - 7:11
    and suddenly, it has substituted
    different text in there.
  • 7:11 - 7:14
    So it's really just a variable.
  • 7:21 - 7:26
    You can also use general entities to
    include files within an XML instance.
  • 7:27 - 7:30
    So for example, here's a DTD...
  • 7:32 - 7:34
    For book. And it's...
  • 7:35 - 7:39
    You, within it, define three entities
    for chapter one, two, and three.
  • 7:40 - 7:42
    And then, within your...
  • 7:45 - 7:49
    ... book, where you want to include
    chapters one, two, and three,
  • 7:49 - 7:54
    when you transform this document,
    it's going to take the contents of
  • 7:54 - 8:00
    these XML files that you've defined here
    as chapters one, two, and three XML.
  • 8:00 - 8:05
    When you publish this book, it's going
    to insert them at those places within...
  • 8:06 - 8:06
    all your documents.
  • 8:06 - 8:09
    So this is very, very similar to what
    you need to do for the recipes
  • 8:09 - 8:12
    in the cookbook. You're going to
    have something very similar to this
  • 8:12 - 8:15
    at your cookbook file,
    and it's going to
  • 8:15 - 8:18
    have some sort of title and
    some sort of introduction;
  • 8:18 - 8:19
    and then you're going to insert
  • 8:19 - 8:22
    each of your recipes in order,
    in the same fashion.
  • 8:22 - 8:27
    And you'll create an entity like this,
    that will point to your recipes.
  • 8:27 - 8:32
    So for example, you might have
    Entity Recipe 1, System.
  • 8:32 - 8:34
    Recipe 1.XML.
  • 8:35 - 8:40
    Entity Recipe 2 System,
    Recipe2.XML.
  • 8:40 - 8:45
    So, these entities are going to
    point to your XML files
  • 8:45 - 8:50
    for each of your recipes, and then you're
    going to insert those entities here,
  • 8:50 - 8:54
    and then, when you transform
    the document, it's going to take
  • 8:54 - 8:58
    the contents of each of your individual
    recipes and add it back in...
  • 8:59 - 9:00
    to the document.
  • 9:00 - 9:05
    And so, that's a way, for example,
    say that you were writing, uh...
  • 9:06 - 9:11
    —a software manual, and some chapters
    might appear in like, multiple books.
  • 9:11 - 9:14
    Say that you have a user guide
    and a reference guide,
  • 9:14 - 9:19
    and a getting-started guide that's
    all talking about the same product.
  • 9:20 - 9:25
    If the... Chapter One is some sort of
    overview that describes the software,
  • 9:25 - 9:28
    and you want it to be in
    each of those books;
  • 9:28 - 9:31
    you would only have to define
    that Chapter One once,
  • 9:31 - 9:35
    and then, include it... in the—
  • 9:35 - 9:37
    do it as a parameter reference;
  • 9:37 - 9:42
    I mean, as a general entity
    reference—in each of those books.
  • 9:42 - 9:45
    So it's a way to be able to reuse files,
    and once you get into DITA,
  • 9:45 - 9:48
    you're going to see that
    DITA kinda does this a lot.
  • 9:49 - 9:54
    It's going to be a totally different
    mechanism than DITA when we get there;
  • 9:54 - 9:56
    but it's kind of doing the same thing.
  • 9:56 - 9:59
    It's basically, you're making,
    like a shell file.
  • 10:00 - 10:03
    That you're gonna run the
    transform on, but that file can point
  • 10:03 - 10:06
    to different files; to additional files,
    so that when you run it,
  • 10:06 - 10:11
    you get all the content of
    all the files you're pointing at; um...
  • 10:11 - 10:14
    To make a single deliverable.
  • 10:16 - 10:18
    And we'll go through this
    some more as we...
  • 10:21 - 10:22
    ... work on this.
  • 10:23 - 10:25
    So here is, uh...
  • 10:29 - 10:32
    The other type of parameter
    that we're talking about;
  • 10:33 - 10:36
    that would let us re-use DTD structures.
  • 10:40 - 10:41
    And in the, uh...
  • 10:42 - 10:45
    So for example, in this one.
  • 10:45 - 10:47
    What we're trying to reuse...
  • 10:48 - 10:51
    is this contact's name;
    last name, first name.
  • 10:51 - 10:57
    So we have this specification
    that we've done for contacts.
  • 10:58 - 11:04
    And then we find out that we wanna
    use contact in a customer list...
  • 11:05 - 11:10
    A contact list of customers, as well
    as in a contact list of employees.
  • 11:10 - 11:13
    Well, the contact information
    is pretty much the same.
  • 11:13 - 11:19
    Some of the other information might
    be different in each of these DTDs.
  • 11:19 - 11:23
    For example, over in this one,
    we have a description;
  • 11:23 - 11:26
    we have the organization name
    and the company name.
  • 11:26 - 11:29
    But each of these,
    besides that information,
  • 11:29 - 11:33
    each of them wants to
    have contact information.
  • 11:33 - 11:37
    So instead of defining it in both
    the contact list for customers
  • 11:37 - 11:42
    and in the contact list for employees,
    you can define in a separate file
  • 11:42 - 11:44
    the information for contacts.
  • 11:44 - 11:48
    And then within the
    contact list for customers
  • 11:48 - 11:53
    and the contact list for employees,
    you create an entity.
  • 11:53 - 11:58
    And the entity's going to point to
    the DTD for contact simple.
  • 12:00 - 12:05
    So that when you're wanting to
    create a contact list for customers,
  • 12:05 - 12:09
    you can have that very specific information
    for customers in the introduction,
  • 12:09 - 12:12
    and then use the...
  • 12:12 - 12:14
    —the standard definition for contact,
    and the same is true for employees.
  • 12:14 - 12:19
    You could have that generic
    employee information in front,
  • 12:19 - 12:24
    and then point to the contact information
    to get the structure of the contact.
  • 12:24 - 12:30
    And this lets you reuse your DTD
    structures across multiple DTDs.
  • 12:35 - 12:39
    In both of the examples, the customer
    list and the employee list contains
  • 12:39 - 12:42
    a series of contacts, but the other
    elements in the DTDs are different.
  • 12:44 - 12:46
    Both DTDs can point to the contact DTD
  • 12:46 - 12:49
    to pull the structure
    from the DTD document.
  • 12:51 - 12:52
    The parameter—
  • 12:52 - 12:58
    The syntax for doing this
    is that you would say, "entity."
  • 13:01 - 13:04
    Percent sign. Contact.
  • 13:04 - 13:08
    System, to indicate that it's a file on your
    system; and then the name of the file.
  • 13:09 - 13:12
    If you were going to do it this way,
    because we don't have a path here,
  • 13:12 - 13:16
    that DTD would have to be in the
    same folder as the other DTDs.
  • 13:18 - 13:25
    And then you would also need to say,
    percent-sign, contact, semi-colon.
  • 13:25 - 13:28
    And this is the same structure that we
    used [inaudible]
  • 13:28 - 13:33
    ampersand, and stuff like that, almost.
  • 13:36 - 13:38
    It's that same sort of structure.
  • 13:38 - 13:41
    The entity statement
    only defines the entity.
  • 13:41 - 13:47
    So this line here, actually only defines
    that this entity exists.
  • 13:48 - 13:54
    It doesn't actually get inserted until
    you put the percent-sign, contact,
  • 13:54 - 13:57
    semi-colon. That actually uses it.
  • 13:57 - 14:02
    I usually put these things together
    in a DTD, but you don't really have to.
  • 14:02 - 14:07
    You just have to make sure that
    you define what the entity is
  • 14:07 - 14:08
    before you actually use it.
  • 14:08 - 14:12
    So this has to come, this line has to
    come somewhere in the file
  • 14:12 - 14:19
    before you insert the percent-sign,
    contact, semi-colon,
  • 14:19 - 14:23
    because otherwise, it would hit this
    and the transform will break,
  • 14:23 - 14:26
    because it won't be able to find this.
  • 14:26 - 14:29
    Or the validation to the DTD will break
    because it wouldn't be able to find it
  • 14:29 - 14:31
    because it hasn't been defined yet, so.
  • 14:32 - 14:34
    You have to define this verse,
  • 14:34 - 14:39
    and this line is actually
    what uses it within the file.
  • 14:47 - 14:50
    When you are to go to use
    the contact list for customers,
  • 14:50 - 14:54
    you wouldn't really notice, in the
    authoring environment, a difference.
  • 14:54 - 14:56
    It would still have all of
    the elements available;
  • 14:56 - 14:58
    same Oxygen in the elements window;
  • 14:58 - 15:02
    you really couldn't tell the difference
    as you're creating the document.
  • 15:02 - 15:04
    The difference is all in the back end.
  • 15:04 - 15:10
    But the authoring experience is the same;
    the contact element would be available
  • 15:12 - 15:16
    seamlessly into the contact list of
    customers; they wouldn't notice
  • 15:16 - 15:19
    that this contact is actually
    defined in a different DTD.
  • 15:19 - 15:22
    The person authoring really
    doesn't care; it's all in the back end,
  • 15:22 - 15:25
    and it will let you put the
    elements where they belong.
  • 15:26 - 15:28
    Also notice that the DTD—
  • 15:29 - 15:34
    I mean, the XML instance
    only refers to that one DTD.
  • 15:34 - 15:39
    It only refers to the bigger one
    that's pointing to the littler one;
  • 15:39 - 15:44
    or the shell DTD pointing to
    the child DTD, so to speak.
  • 15:44 - 15:48
    So you wouldn't have a doc-type
    statement for both of those files;
  • 15:48 - 15:52
    you would only have it for the one
    that is including the other file.
  • 15:54 - 15:57
    'Cause it's sort of like the,
    defining the overall structure
  • 15:57 - 16:02
    while the contact DTD is only
    describing one small piece of it.
  • 16:08 - 16:11
    The DTD that pulls in another DTD
    is sometimes called a shell DTD,
  • 16:11 - 16:15
    and you'll see this a lot in DITA;
    they'll have—um.
  • 16:15 - 16:17
    And the reason they do this is, like—
  • 16:18 - 16:21
    We'll go into DITA a lot more in
    the second half of the semester,
  • 16:21 - 16:27
    but DITA defines four different
    types of topics at the base level.
  • 16:27 - 16:29
    There's concept, fast reference,
  • 16:29 - 16:33
    and then there's regular topic;
    kind of a generic topic.
  • 16:33 - 16:38
    And the reason that they use parameter
    entities is because there's these
  • 16:38 - 16:43
    low-level elements such as Paragraphs,
    Notes, Lists, things like that;
  • 16:43 - 16:47
    that they only wanna define in one place.
    All topics will include those elements.
  • 16:47 - 16:50
    All topics types will have
    paragraphs in them,
  • 16:50 - 16:53
    and they'll have loose items in them,
    and they'll have notes in them,
  • 16:53 - 16:56
    and things like that, but they
    only wanna define it once.
  • 16:56 - 17:02
    So they create a DTD that defines
    all those basic elements, um...
  • 17:02 - 17:08
    and then they'll create another DTD
    that pulls those elements
  • 17:08 - 17:11
    from that common DTD into them.
  • 17:11 - 17:16
    So, they can define things one time;
    all of the element structures;
  • 17:16 - 17:19
    all of the details of these
    elements in one place,
  • 17:19 - 17:21
    and then they can reuse
    them in multiple topics.
  • 17:22 - 17:28
    So that's really why we
    kind of use these structures,
  • 17:28 - 17:32
    is just to be able to define
    commonly used things in one place,
  • 17:32 - 17:34
    and use them across
    all of the DTDs,
  • 17:34 - 17:37
    or all of the structures that
    you need to use them.
  • 17:38 - 17:45
    And when we have a DTD like this,
    where we're pulling in, basically,
  • 17:45 - 17:51
    the information from another DTD,
    we sometimes call those a shell DTD.
  • 17:51 - 17:54
    Because what they are is they're
    providing like, the infrastructure
  • 17:54 - 17:57
    or the shell in which all the
    other details will be added.
  • 17:58 - 18:02
    And you'll see this when
    you're thinking about your...
  • 18:05 - 18:06
    Recipes, in your cookbook.
  • 18:06 - 18:08
    The cookbook's going to be a shell DTD.
  • 18:08 - 18:12
    It's going to be pointing
    to those other...
  • 18:13 - 18:16
    —the DTDs for recipes,
    to pull in their structure.
  • 18:16 - 18:20
    So that's where this is gonna really apply
    when you're working on your project,
  • 18:20 - 18:23
    and you'll see, hopefully,
    how all that will work together.
  • 18:27 - 18:30
    And that's pretty much where, um...
  • 18:31 - 18:33
    we're going to end
    this part of the lecture.
  • 18:33 - 18:35
    I wanna step back one more...
  • 18:37 - 18:42
    One more time...
    to a previous slide.
  • 18:43 - 18:49
    And just really draw your attention
    to this particular slide.
  • 18:50 - 18:57
    Because this is really, describing almost
    exactly how you're going to put your
  • 18:57 - 19:00
    recipes together into the cookbook.
  • 19:00 - 19:06
    So, when you get to your cookbook,
    your recipes in your cookbook,
  • 19:06 - 19:09
    you're going to create a DTD.
  • 19:11 - 19:15
    And you're going to, you know.
    Add the three recipes to it.
  • 19:15 - 19:17
    And then you're also going to...
  • 19:18 - 19:23
    Uh, point, just like I'm pointing
    to contact, right here.
  • 19:23 - 19:24
    I'm sorry.
  • 19:26 - 19:27
    Contact, here.
  • 19:28 - 19:32
    You're going to have
    something for recipe like this,
  • 19:32 - 19:33
    where you're gonna have
    your element recipe, and...
  • 19:33 - 19:36
    whatever pieces
    make up your recipe.
  • 19:36 - 19:40
    You're gonna have a separate file,
    a DTD file, just for your recipe;
  • 19:40 - 19:42
    and then you're going to have
    some sort of file like this
  • 19:42 - 19:45
    contact list customers file
    that's going to have—
  • 19:46 - 19:48
    Instead of contact list customer,
    it's gonna be like your cookbook,
  • 19:48 - 19:53
    and it could have a title.
    It might have a description.
  • 19:53 - 19:56
    And then it's going to, where this says
    "Organization" and a plus sign,
  • 19:56 - 20:00
    you're probably gonna have something
    that says "Recipes" and a plus sign.
  • 20:00 - 20:03
    And then here, uh...
  • 20:09 - 20:12
    You'll have something
    that basically says...
  • 20:14 - 20:15
    Entity...
  • 20:18 - 20:19
    Percent sign.
  • 20:21 - 20:27
    Recipe system.
    Recipe-dot... DTD?
  • 20:28 - 20:32
    And then you'll have
    something here that would say...
  • 20:33 - 20:35
    Percent-sign, recipe, semi-colon.
  • 20:36 - 20:40
    And that would be, really, how you
    would define that cookbook structure.
  • 20:41 - 20:46
    So, I'm going to close this
    part of the lecture down now,
  • 20:46 - 20:48
    and record the final piece.
  • 21:30 - 21:33
    Okay, so the first part of
    week five's lecture,
  • 21:33 - 21:37
    we're gonna do a very, very,
    very brief introduction to CSS.
  • 21:38 - 21:40
    I know some people are familiar with CSS.
  • 21:41 - 21:43
    CSS just stands for Cascading Style Sheet,
  • 21:43 - 21:48
    and it's the way that you apply styles
    to XML and HTML documents.
  • 21:49 - 21:54
    Without CSS, you can use HTML tags
    to structure your document,
  • 21:54 - 21:56
    and the browser will format the
    elements using default values.
  • 21:56 - 22:00
    So, the browser will make it
    look like something.
  • 22:03 - 22:07
    But CSS allows you to provide
    specific formatting properties
  • 22:07 - 22:10
    so that you can give your
    document a unique look.
  • 22:15 - 22:16
    And here's an example.
  • 22:18 - 22:22
    This particular... it's the
    HTML output for resume.
  • 22:23 - 22:26
    And it has no cascading style sheet.
  • 22:26 - 22:29
    It's just basically using
    the default attributes;
  • 22:29 - 22:34
    the way that tags look by default
    within an HTML browser.
  • 22:35 - 22:40
    This is like an H1 element,
    and then these are paras,
  • 22:40 - 22:45
    and then there's like, a B tag for
    bola to apply to Career Focus;
  • 22:45 - 22:50
    and then maybe another B tag
    applied to Experience Summary,
  • 22:50 - 22:53
    and then a bullet list... Um...
  • 22:53 - 22:56
    But there's no extra
    CSS added to this;
  • 22:56 - 23:01
    it's just out-of-the-box what it would
    look like if you open an HTML, um...
  • 23:01 - 23:06
    file that's using HTML tags with no
    cascading style sheets associated with it.
  • 23:09 - 23:13
    What the cascading style sheets does is
    let you kind of redefine the appearance
  • 23:13 - 23:19
    of the default values for the elements,
    and kind of make things look different.
  • 23:19 - 23:22
    This is better-looking;
    this still isn't, um,
  • 23:22 - 23:24
    something a web designer
    would be proud of,
  • 23:24 - 23:28
    but it's showing you at least there's
    some basic CSS that you can apply,
  • 23:28 - 23:32
    and make something look a lot better
    than it does with its default tags.
  • 23:32 - 23:34
    Let's go back and compare again.
  • 23:34 - 23:38
    Here's the default. Kind of generic;
    using Times Roman.
  • 23:39 - 23:43
    You know. Gets the job done, but
    it's not particularly attractive.
  • 23:44 - 23:47
    But once CSS is applied, you can
    put a lot more details in it
  • 23:47 - 23:49
    and make it look a lot better.
  • 23:55 - 23:59
    There's two ways that you can add
    the CSS to your XSL file.
  • 24:00 - 24:02
    I'm going to show you the way
    that I don't recommend first,
  • 24:02 - 24:05
    so that it will make the one I do
    recommend that much better.
  • 24:06 - 24:11
    You can actually, in your XSLT file,
    just add the style statements,
  • 24:11 - 24:14
    and they belong right after the title.
  • 24:15 - 24:20
    And you can just build out your style,
    and kinda specify the different styles
  • 24:20 - 24:25
    that you would like to apply
    to this particular HTML file.
  • 24:25 - 24:29
    And so then when you ran the
    transform in your HTML file,
  • 24:29 - 24:31
    it would actually insert
    all these style statements,
  • 24:31 - 24:34
    and then when it's rendered in the browser,
    the browser would apply these styles.
  • 24:36 - 24:42
    You have to make sure that you put it
    in the right location, in your XSLT file.
  • 24:44 - 24:48
    Browsers tend to be very forgiving
    and probably will try to still style it
  • 24:48 - 24:50
    if you put it in the wrong place,
    but it wouldn't really be valid,
  • 24:50 - 24:52
    and you might get
    unpredictable results.
  • 24:52 - 24:55
    So make sure that if you
    were to do it this way,
  • 24:55 - 25:00
    that you would put it in the
    proper place, right after title...
  • 25:00 - 25:02
    within the head section.
  • 25:06 - 25:10
    The other, better alternative is
    instead of actually inserting the styles
  • 25:10 - 25:16
    inside your XSLT file, is that you put
    the styles in another style sheet.
  • 25:17 - 25:19
    In another file.
  • 25:20 - 25:21
    And then just point to the file.
  • 25:21 - 25:27
    For example, here, the styles
    have been defined in this file,
  • 25:27 - 25:31
    called Resume_style.css,
  • 25:32 - 25:34
    and you just create this link to it,
  • 25:34 - 25:40
    and so then when it's outputted through
    the transformation rendition,
  • 25:40 - 25:46
    it will, in your resulting output, will
    make a pointer to that CSS file.
  • 25:46 - 25:55
    And the advantage this has is,
    say that you've got 100 XML files,
  • 25:55 - 26:00
    and you run the transform and turn
    these 100 XML files into HTML files.
  • 26:00 - 26:03
    That you've inserted your styles
    directly into the file.
  • 26:05 - 26:09
    And then you realize that you were
    supposed to make something blue,
  • 26:09 - 26:11
    instead of red.
  • 26:12 - 26:16
    If you have the styles directly
    inside your HTML files,
  • 26:16 - 26:18
    and wasn't pointing to an external file,
  • 26:18 - 26:24
    then you would have to
    go fix the XSLT file,
  • 26:24 - 26:26
    and then run those 100 transforms again.
  • 26:27 - 26:31
    But if you were to externalize it and
    have a CSS file that they just point to,
  • 26:31 - 26:37
    you have that single CSS file;
    all 100 HTML files point to it.
  • 26:38 - 26:41
    Then you would only have to
    make the change in the CSS file;
  • 26:41 - 26:43
    wouldn't have to re-run
    those 100 transformations.
  • 26:43 - 26:45
    You'd only have to make
    the change in one place.
  • 26:45 - 26:49
    And that's what you hear me talk
    about all the time in this course,
  • 26:49 - 26:54
    is that what you're really trying to do
    is to make single-source things
  • 26:54 - 26:58
    so that you don't have to do the
    same work over and over again.
  • 26:58 - 26:58
    So by having your styles
    in a separate file,
  • 26:58 - 27:06
    you enable it to be in one place
    so that if you need to change it,
  • 27:06 - 27:10
    you can without regenerating the
    transformation for those 100 files.
  • 27:10 - 27:15
    So, the takeaway from this is,
    try to use...
  • 27:18 - 27:20
    This. Adding style to
    external style sheet.
  • 27:20 - 27:27
    And that's true whether you're
    developing HTML pages directly,
  • 27:27 - 27:31
    or using XML and transforming
    them to HTML.
  • 27:31 - 27:34
    It's really just a best practice to
    always try to externalize your styles
  • 27:34 - 27:38
    and have them in a separate file
    so that you can change them easily
  • 27:38 - 27:41
    and have that apply across the board.
  • 27:46 - 27:49
    We're going to kinda go through
    now the syntax of CSS rule.
  • 27:49 - 27:53
    It will kind of remind you
    of the XSLT rules, actually.
  • 27:53 - 27:55
    But it's formatted
    a little bit differently.
  • 27:57 - 28:01
    Basically, a CSS rule
    will have a selector,
  • 28:03 - 28:06
    and then the declaration. So for example,
    in this one, the body is the element.
  • 28:06 - 28:09
    We're telling it what we
    want the style applied to.
  • 28:09 - 28:14
    And then the declaration is
    what styles are being applied.
  • 28:16 - 28:19
    And declarations are always
    included in the curly braces.
  • 28:20 - 28:25
    There will be a name of the property
    at the attribute that you're changing.
  • 28:25 - 28:27
    In this case, it's font family.
  • 28:28 - 28:32
    If you have more than one,
    they're separated by a semi-colon.
  • 28:33 - 28:38
    The property is separated
    from the value by a colon.
  • 28:42 - 28:44
    If you wanted to, you could
    have these on separate lines.
  • 28:44 - 28:49
    You could have font family, colon,
    arial, one line, hit return, and put
  • 28:49 - 28:53
    font-dash-size, semi-colon, 20px.
  • 28:54 - 29:02
    I mean: font-hyphen-size, colon, 20px,
    semi-colon, on the next line down.
  • 29:02 - 29:06
    So you can have them on
    separate lines if you want,
  • 29:06 - 29:10
    but you always do need to have
    the semi-colon at the end.
  • 29:10 - 29:13
    Even if you only have one property here,
  • 29:13 - 29:15
    you still need to put the semi-colon.
  • 29:16 - 29:18
    You just always need that.
  • 29:22 - 29:26
    Here's a few of the common properties
    that you might wanna specify.
  • 29:26 - 29:29
    Font-family is the type of font
    you wanna use; it could be Arial,
  • 29:29 - 29:34
    it could be Times Roman; it's whatever
    the font that you want to use.
  • 29:35 - 29:39
    Font-style, actually, is whether
    you want an element to be...
  • 29:39 - 29:43
    italic, oblique, or normal.
    It's basically making italics.
  • 29:44 - 29:47
    Font-size specifies the size
    of the font, and if you look...
  • 29:49 - 29:51
    The "px" here stands for pixels.
  • 29:51 - 29:55
    So, this is a 20-pixel font.
    So it's just the—
  • 29:56 - 29:59
    Pretty much the same thing
    that you would see in Word,
  • 29:59 - 30:03
    where you're taking a font size
    to make things bigger and smaller.
  • 30:04 - 30:09
    If you wanted the font size to be bigger
    than 20 pixels, you would make it 24;
  • 30:09 - 30:13
    you know, 32, or... or something
    like that. You could make it smaller.
  • 30:14 - 30:16
    So that's what font-size does.
  • 30:17 - 30:21
    Font-weight is basically whether
    you want it bold or not.
  • 30:22 - 30:26
    List-style specifies the
    styles for lists, margins.
  • 30:26 - 30:28
    Lets you put margins around an element,
  • 30:28 - 30:33
    or you can also use padding instead,
    that's based around an element.
  • 30:33 - 30:37
    And then text-align is another one
    that might be commonly used...
  • 30:38 - 30:43
    to specify the alignment of
    the text on the right or left.
  • 30:44 - 30:49
    And this link. Uh, I'm not sure that
    it's going to show it when I go there.
  • 30:50 - 30:55
    No, it's not. So, let me re-share
    my desktop in a different way.
  • 31:12 - 31:15
    Give me a moment to try to
    catch up. I thought I shared it.
  • 31:17 - 31:18
    There we go.
  • 31:19 - 31:25
    W3Schools has a reference section
    on CSS, and the link's in there.
  • 31:25 - 31:27
    And it's going to tell you...
  • 31:27 - 31:30
    all of the different properties
    in this reference section.
  • 31:31 - 31:35
    So for example. Now I'm scrolling
    fast, but I'll let it catch up.
  • 31:36 - 31:40
    So for example, if you
    go to the font section.
  • 31:46 - 31:51
    There's all sorts of different
    font values that you can specify,
  • 31:51 - 31:58
    and you can come here and
    see the different values for like,
  • 31:58 - 32:03
    font-size, -family, -stretch, -style.
    You know, and this reference is a good
  • 32:03 - 32:09
    beginning reference to get your
    head around HTML and CSS.
  • 32:09 - 32:12
    So you can come here and kinda
    see what the different values;
  • 32:12 - 32:16
    like if you wanted to play with font-weight,
    you could click on font-weight,
  • 32:16 - 32:20
    and it's going to tell you what values
    you can enter, and you also will see...
  • 32:26 - 32:28
    This Try It Yourself button.
  • 32:29 - 32:31
    And when you click it on Try It Yourself.
  • 32:34 - 32:39
    It opens up this window that has
    two different sub-windows in it,
  • 32:39 - 32:43
    and you can play with the
    values here, on W3Schools,
  • 32:43 - 32:47
    to see what the different
    things might do.
  • 32:49 - 32:51
    So, you know, they are basically...
  • 32:53 - 32:57
    putting out different values, and you can
    come up here, and you could change...
  • 32:57 - 33:01
    the values, and see what effect it has
    in this other window by submitting code.
  • 33:02 - 33:07
    And this is just a great way to kinda
    test the different values and see
  • 33:07 - 33:09
    what results you might get.
  • 33:09 - 33:14
    So, I highly recommend
    coming out and playing with
  • 33:14 - 33:20
    the different CSS values at w3Schools,
    and kind of going through these
  • 33:20 - 33:23
    Try It Yourself buttons, and kind of
    playing with the text,
  • 33:23 - 33:27
    and seeing what different
    effects you might get from
  • 33:27 - 33:29
    changing different
    properties different ways.
  • 33:31 - 33:37
    For your homework, you really don't
    have to do a lot of CSS work.
  • 33:38 - 33:44
    As long as your output is presentable
    and isn't all jumbled into a big mess,
  • 33:45 - 33:49
    I'm not gonna require for you to actually
    do a lot of Cascading Style Sheets work
  • 33:49 - 33:53
    if you don't want to, but if
    you want to actually...
  • 33:55 - 33:59
    It's just very important
    to understand CSS
  • 33:59 - 34:02
    if you're going to do
    any online work at all,
  • 34:02 - 34:06
    so I do highly recommend; and there's
    other classes that really focus on CSS.
  • 34:07 - 34:12
    There's one that you can take in the
    Technical & Business Communications
  • 34:12 - 34:15
    Department called "XHTML in CSS."
  • 34:15 - 34:18
    And then there's also, in the Visual
    Communications department,
  • 34:18 - 34:21
    several classes on web design.
    And I think it's just, uh...
  • 34:23 - 34:27
    Something that I would highly
    recommend that you look into.
  • 34:27 - 34:30
    I can't cover it a lot in this class,
    'cause we just have simply
  • 34:30 - 34:34
    too much to do with just getting the
    basics of XML down.
  • 34:35 - 34:38
    But it's really, uh.
  • 34:39 - 34:41
    Is—Are skills that you really need to do
  • 34:41 - 34:43
    if you wanna go into a career
    of technical writing;
  • 34:43 - 34:46
    is to understand how
    Cascading Style Sheets work,
  • 34:46 - 34:49
    and how styles are defined,
    and how to apply styles.
  • 34:50 - 34:55
    So I highly recommend that, and
    also to take classes in web design,
  • 34:55 - 34:58
    and HTML and CSS class.
  • 34:58 - 35:01
    I think they're actually required
    for the degree, I think?
  • 35:02 - 35:04
    I won't guarantee that,
    because things changed.
  • 35:05 - 35:11
    But if not now [chuckles],
    do study CSS in the future,
  • 35:11 - 35:16
    because you absolutely
    will need to know that,
  • 35:16 - 35:20
    if you're going to work on anything
    online. And a lot of documentation,
  • 35:20 - 35:26
    and a lot of technical writing is actually
    being delivered online these days, so.
  • 35:27 - 35:32
    Highly recommend coming out here
    and playing with the CSS tutorial...
  • 35:33 - 35:37
    at the W3Schools, and also make sure
    that you take additional classes
  • 35:37 - 35:39
    in that, if you haven't already.
  • 35:49 - 35:51
    And I'm going back to our...
  • 36:03 - 36:07
    Selectors can also use classes to identify
    elements upon which to apply styles.
  • 36:09 - 36:11
    Classes allow the style based
    on an assigned class name
  • 36:11 - 36:13
    instead of an HTML element name.
  • 36:13 - 36:18
    And this is important for like, if you
    wanted a paragraph in an address,
  • 36:18 - 36:23
    for example, to be formatted different
    than a paragraph in a heading,
  • 36:23 - 36:26
    or below a heading, or a description,
    or something like that.
  • 36:26 - 36:29
    You can assign class statements so that...
  • 36:30 - 36:35
    You can specify that a
    paragraph in one context
  • 36:35 - 36:38
    looks different than a
    paragraph in another context.
  • 36:40 - 36:45
    And the syntax for using a CSS class
    is putting the element name,
  • 36:45 - 36:48
    a period, then the class name,
  • 36:48 - 36:51
    and then the property, the semi-colon,
    the value, and the semi-colon.
  • 36:51 - 36:55
    So for example, if you wanted,
  • 36:55 - 36:59
    for the P tags, paragraphs.
  • 37:01 - 37:06
    With the class of zip code, you could
    set font-size, semi-colon, 12 pixels...
  • 37:07 - 37:10
    Semi-colon. And then that would only...
  • 37:13 - 37:16
    When the transform's happening,
    the browser actually...
  • 37:16 - 37:21
    this is when the browser's reading
    the file, so it's in your HTML file.
  • 37:22 - 37:28
    You could have <p class="address">,
    and that would be formatted differently
  • 37:28 - 37:32
    than <p class="school">, because
    you have these styled differently.
  • 37:32 - 37:38
    P-dot-address has a margin of zero
    points, and text alignment center,
  • 37:38 - 37:42
    while p-dot school—period-school—
    has a font-weight of bold.
  • 37:42 - 37:46
    So you just add this—it's an attribute.
  • 37:46 - 37:49
    We've all seen attributes before,
    but the attribute name is class,
  • 37:49 - 37:53
    and then you make up
    a name for this part of it.
  • 37:53 - 37:56
    You know, address, school; it could
    be Fred. I mean, it doesn't matter.
  • 37:56 - 38:03
    But in your style section, you
    have to have the element name,
  • 38:03 - 38:05
    period, and the class name,
  • 38:05 - 38:10
    and then you can specify styles that
    are specific for that combination.
  • 38:15 - 38:20
    In your XSLT, you would just do that
    by when you're defining your values,
  • 38:20 - 38:24
    and you know, you're building
    out your HTML formatting;
  • 38:24 - 38:26
    you can just add the class statements...
  • 38:32 - 38:33
    Oops. Sorry.
  • 38:34 - 38:37
    You could just add the class
    statements to the paragraphs...
  • 38:39 - 38:41
    as you're defining out your XSLT.
  • 38:44 - 38:48
    And then when the transform happens, it
    will insert those into your HTML output,
  • 38:48 - 38:51
    and then when you look at
    the page in a browser,
  • 38:51 - 38:54
    it will format the page
    using those class values.
  • 38:59 - 39:02
    And this demo is just a really
    basic overview of CSS,
  • 39:02 - 39:06
    so that you can begin to apply a few
    styles to your resume. Like I said,
  • 39:06 - 39:14
    I'm not going to really grade you on any
    sort of elaborate CSS work in your file;
  • 39:14 - 39:20
    I really want you to focus on getting
    your XML output into valid HTML output;
  • 39:20 - 39:27
    but if you want to really extend those
    skills, you need to start looking at CSS.
  • 39:27 - 39:32
    And like I said, it won't affect your
    grade, really, for this class too much;
  • 39:32 - 39:34
    and I hope this site's still here.
  • 39:35 - 39:37
    Uh, let's see; can I share that?
  • 40:00 - 40:03
    Okay, I wanted to share this website,
    and let's see if I can.
  • 40:04 - 40:10
    There's a website called
    www.csszengarden.com.
  • 40:10 - 40:15
    And what that website does—and I'll
    try to share back over there.
  • 40:15 - 40:19
    And I'm sorry; I know things
    start getting kinda...
  • 40:21 - 40:27
    Not as attractive,
    and laggy, when I, uh...
  • 40:29 - 40:32
    Attempt to share things
    outside of the browser,
  • 40:32 - 40:34
    but let's see if I can get this to work.
  • 40:34 - 40:36
    And what the Zen Garden website is
  • 40:36 - 40:40
    is it's a website that takes
    the same basic HTML,
  • 40:40 - 40:46
    and it applies different styles to it
    to show you what you can do,
  • 40:46 - 40:48
    just using different style sheets.
    Same HTML underneath;
  • 40:48 - 40:52
    it's the same structure and
    all the same HTML tags,
  • 40:52 - 40:57
    but it can look completely different
    depending on the CSS that you apply to it.
  • 40:57 - 40:59
    So, for example...
  • 41:02 - 41:05
    Here's one design.
  • 41:12 - 41:13
    It's the same HTML file underneath;
  • 41:13 - 41:17
    what they've done is they've
    created a style sheet for it;
  • 41:19 - 41:23
    and that style sheet has a very
    specific look and design to it.
  • 41:28 - 41:30
    And I will stop there, so...
  • 41:35 - 41:39
    You can see a little bit of
    what this page looks like.
  • 41:42 - 41:47
    And then, you know, we could pick
    another design for the same text.
  • 41:47 - 41:49
    Same HTML file.
  • 41:52 - 41:54
    And it will have a
    completely different look.
  • 42:10 - 42:14
    And it's all done through the
    power of cascading style sheets,
  • 42:14 - 42:18
    and just formatting them different
    depending on the different contacts.
  • 42:19 - 42:22
    So, I love this website just
    because it lets you download
  • 42:22 - 42:28
    the HTML and the CSS codes so you can
    kinda see what the differences are.
  • 42:28 - 42:31
    You don't have to, of course,
    do that for this class or anything,
  • 42:31 - 42:36
    but I just—a teacher a long time showed
    this to me, and I keep using it as an
  • 42:36 - 42:39
    example to show you, really, the power
    of CSS and Cascading Style Sheets.
  • 42:40 - 42:41
    So, uh.
  • 42:42 - 42:48
    If you have a chance; and not a high
    priority, but that website's pretty cool.
  • 42:49 - 42:53
    It'll really kinda highlight everything
    that you can do with CSS, so.
  • 42:54 - 42:57
    I'm going to stop the lecture here.
  • 42:57 - 43:01
    If you have any questions, please
    post them in the discussion board,
  • 43:01 - 43:05
    and uh... I will record
    another lecture next week.
  • 43:05 - 43:09
    And remember, my office hours are
    Wednesday night from 8 to 10 PM,
  • 43:09 - 43:13
    and on Saturday morning
    from 10 to noon.
  • 43:14 - 43:18
    So, I'll talk to y'all later.
    Thank you for listening.
Title:
https:/.../xml_css_entities.mp4
Video Language:
English
Duration:
43:57

English subtitles

Revisions