Can I 'apply-templates' across multiple XML documents?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 71
- Joined: Fri Apr 30, 2004 8:00 pm
- Location: Texas
Can I 'apply-templates' across multiple XML documents?
A simple version of what I have it this:
Basically, for ease of re-use, I have separated my schemas across multiple files.
What I have above is not working.
Is this even possible?
Code: Select all
<!-- First, declare the external XML document -->
<xsl:variable name="generic-common-xsd" select="document('../XSD/Common/NMIE-Generic-Common.xsd')"></xsl:variable>
<!-- Do some processing in the root XML document, then at some point
I need to process something in the other XML document -->
<xsl:element name="Value">
<xsl:apply-templates select="$generic-common-xsd/xs:simpleType[@name='$TypeVal']" mode="Type"></xsl:apply-templates>
</xsl:element>
<!-- Doing this with a template seemed the most logical way, but doesn't seem to work -->
<xsl:template match="xs:simpleType" mode="Type">
<xsl:element name="Domain"></xsl:element>
</xsl:template>
What I have above is not working.
Is this even possible?
--------------------------
- mike
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
- mike
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Hi Mike,
As I see it, you have an omission in the xpath used in the "xsl:apply-templates".
It should be like:
Notice the additional "xs:schema" in the path.
Here is your stylesheet adapted to work with the Oxygen "samples/personal.xsd" file.
Regards, Radu
As I see it, you have an omission in the xpath used in the "xsl:apply-templates".
It should be like:
Code: Select all
<xsl:apply-templates select="$generic-common-xsd/xs:schema/xs:simpleType[@name='$TypeVal']"
Here is your stylesheet adapted to work with the Oxygen "samples/personal.xsd" file.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<!-- First, declare the external XML document -->
<xsl:variable name="generic-common-xsd"
select="document('personal.xsd')"/>
<!-- Do some processing in the root XML document, then at some point
I need to process something in the other XML document -->
<xsl:element name="Value">
<xsl:apply-templates select="$generic-common-xsd/xs:schema/xs:element[@name='personnel']"
mode="elem"/>
</xsl:element>
</xsl:template>
<!-- Doing this with a template seemed the most logical way, but doesn't seem to work -->
<xsl:template match="xs:element" mode="elem">
<xsl:value-of select="@name"/>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 71
- Joined: Fri Apr 30, 2004 8:00 pm
- Location: Texas
Using a variable for the document() reference doesn't seem to be working.
I replaced it with:
And it's a lot happier.
But I've had to hard-code the attribute target ('SerialNumberType') rather than use a variable
I need this to be dynamic as I scoot through the document.
and the use it as:
And, yes, you are correct the single quotes were in error.
However, this is not calling the template as I would have expected.
Which brings me to a question about Oxy7.2 and the XSLT debugger.
If I set a break point and stop after the setting of the variables, the debugger does not show me the value in the variable. It has the name of all the vaiables. It shows $TypeVal as a local variable, but the value is empty for all variables and parameters.
Any ideas why?
I replaced it with:
Code: Select all
<xsl:element name="Value">
<xsl:apply-templates
select="document('myschema.xsd')/xs:schema/xs:simpleType[@name='SerialNumberType']"
mode="Type"/>
</xsl:element>
But I've had to hard-code the attribute target ('SerialNumberType') rather than use a variable
I need this to be dynamic as I scoot through the document.
Code: Select all
<xsl:variable name="TypeVal" select="string(.//xs:element/@type)"/>
Code: Select all
<xsl:variable name="TypeVal" select="string(.//xs:element/@type)"/>
...
<xsl:element name="Value">
<xsl:apply-templates
select="document('myschema.xsd')/xs:schema/xs:simpleType[@name=$TypeVal]"
mode="Type"/>
</xsl:element>
However, this is not calling the template as I would have expected.
Which brings me to a question about Oxy7.2 and the XSLT debugger.
If I set a break point and stop after the setting of the variables, the debugger does not show me the value in the variable. It has the name of all the vaiables. It shows $TypeVal as a local variable, but the value is empty for all variables and parameters.
Any ideas why?
--------------------------
- mike
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
- mike
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service